﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProcessoSeletivo.DAO;
using System.Web.Security;

public partial class candidato_Default : System.Web.UI.Page
{
    #region " Load "

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["des_login_usu"] = null;
            txtUsuario.Focus();
        }
    }

    #endregion

    #region " Botões "

    protected void imgAutentica_Click1(object sender, ImageClickEventArgs e)
    {
        bool flag = false;

        using (Usuario objUser = new Usuario())
        {
            flag = objUser.ValidarUsuario(txtUsuario.Text, FormsAuthentication.HashPasswordForStoringInConfigFile(txtSenha.Text, "sha1"));
        }

        if (flag)
        {
            Session["des_login_usu"] = txtUsuario.Text;
            Response.Redirect("Principal.aspx");
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "block", "alert('Usuário e senha inválidos!');", true);
        }
    }

    #endregion
}